<%@ page import="com.oval.util.JspHelper" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ page language="java" %>
<%@ page import="java.util.*,com.oval.foundation.metadata.engine.*" %>
<%@ page import="com.oval.foundation.container.VTableContainer" %>

<% String vtableName = request.getParameter("name");
   OvalVTable vtable = (OvalVTable)(VTableContainer.findVTableMeta(vtableName));
   
   String TableAlias = "";
   String strPrimaryTable = "";
   Iterator it = vtable.getFromTables();
   while (it.hasNext())
   {  
     OvalFromTable fromTable=(OvalFromTable)(it.next());
     if(fromTable.getTableName().equalsIgnoreCase(vtable.m_strPrimaryTable))
     {
       if(fromTable.getIsPrimary())
       {
         TableAlias=fromTable.getTableAlias();
		 strPrimaryTable=fromTable.getTableName();
         break;
       }  
     }
   }
   %>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/chinese/csscontent.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td background="images/chinese/title_bg.gif"><img src="images/chinese/title_bg.gif" width="3" height="29"></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="10%" class="red_title">VirtualTable Name:</td>
    <td><%=JspHelper.filterNull( vtableName )%></td>
  </tr>
  <tr>
    <td width="10%" class="red_title">Primary Table Name:</td>
    <td><%=JspHelper.filterNull( strPrimaryTable )%></td>
  </tr>
  <tr>
    <td width="10%" class="red_title">Primary Table From Table Alias:</td>
    <td><%=JspHelper.filterNull( TableAlias)%></td>
  </tr>
  <tr>
    <td width="10%" class="red_title">VTable Description:</td>
    <td><%=JspHelper.filterNull( vtable.getDescription())%></td>
  </tr>
</table>
<script>
  function toggleCols()
  {
    if(colsHide.style.display=='none')
    {
      colsHide.style.display = 'inline';
      colsShow.style.display = 'none';
    }
    else
    {
      colsShow.style.display = 'inline';
      colsHide.style.display = 'none';
    }
  }
  
  function toggleFromTables()
  {
    if(fromTablesHide.style.display=='none')
    {
      fromTablesHide.style.display = 'inline';
      fromTablesShow.style.display = 'none';
    }
    else
    {
      fromTablesShow.style.display = 'inline';
      fromTablesHide.style.display = 'none';
    }
  }
  
  function toggleMappings()
  {
    if(mappingsHide.style.display=='none')
    {
      mappingsHide.style.display = 'inline';
      mappingsShow.style.display = 'none';
    }
    else
    {
      mappingsShow.style.display = 'inline';
      mappingsHide.style.display = 'none';
    }
  }
  
  function toggleQLs()
  {
    if(qlHide.style.display=='none')
    {
      qlHide.style.display = 'inline';
      qlShow.style.display = 'none';
    }
    else
    {
      qlShow.style.display = 'inline';
      qlHide.style.display = 'none';
    }
  }
  
  function toggleCDs()
  {
    if(cdHide.style.display=='none')
    {
      cdHide.style.display = 'inline';
      cdShow.style.display = 'none';
    }
    else
    {
      cdShow.style.display = 'inline';
      cdHide.style.display = 'none';
    }
  }
  
  function toggleCVs()
  {
    if(cvHide.style.display=='none')
    {
      cvHide.style.display = 'inline';
      cvShow.style.display = 'none';
    }
    else
    {
      cvShow.style.display = 'inline';
      cvHide.style.display = 'none';
    }
  }
  
  function qltest(vtableName,qlName)
  {
    window.opener.testql(vtableName,qlName);
  }
</script>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="colsHide" onclick="toggleCols()" style="display:inline;">
  <tr> 
    <td colspan="11" class="td_title_bg">
      <img src="images/chinese/arrow3.gif"> 
      Columns
    </td>
  </tr>
</tbody>
<tbody id="colsShow" onclick="toggleCols()" style="display:none;">
  <tr> 
    <td colspan="11" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
      Columns
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">Column Desc Name</td>
    <td class="td_center">Column Name</td>
    <td class="td_center">Column Table Alias</td>
    <td class="td_center">Column Type</td>
    <td class="td_center">Format On Insert</td>
    <td class="td_center">Format On Update</td>
    <td class="td_center">Format On Output</td>
    <td class="td_center">Format On Display</td>
    <td class="td_center">Format On Read</td>
    <td class="td_center">Optional</td>
    <td class="td_center">IsInsertable</td>
    <td class="td_center">isUsable</td>
    <td class="td_center">Description</td>
  </tr>
 <% it = vtable.getColumnNames();
    while(it.hasNext())
    {
      OvalColumn oc = vtable.getColumnByName(it.next().toString());
      %>
  <tr class="td_bg1">
    <td><%=JspHelper.filterNull( oc.getColDesc())%></td>
    <td><%=JspHelper.filterNull( oc.getColName())%></td>
    <td><%=JspHelper.filterNull( oc.getColTableAlias())%></td>
    <td><%=JspHelper.filterNull( oc.getColType())%></td>
    <td><%=JspHelper.filterNull( oc.getFormatIn())%></td>
    <td><%=JspHelper.filterNull( oc.getFormatUp())%></td>
    <td><%=JspHelper.filterNull( oc.getFormatOut())%></td>
    <td><%=JspHelper.filterNull( oc.getFormatPage())%></td>
    <td><%=JspHelper.filterNull( oc.getFormatRead())%></td>
    <td><%=JspHelper.filterNull( oc.getOption())%></td>
    <td><%=JspHelper.filterNull( oc.getIsInsertable())%></td>
    <td><%=JspHelper.filterNull( oc.getIsUsable())%></td>
    <td><%=JspHelper.filterNull( oc.getDescription())%></td>
  </tr>
 <% } %>
</tbody>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="fromTablesHide" onclick="toggleFromTables()" style="display:inline;">
  <tr> 
    <td colspan="5" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
      From Tables
    </td>
  </tr>
</tbody>
<tbody id="fromTablesShow" onclick="toggleFromTables()" style="display:none;">
  <tr> 
    <td colspan="5" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
      From Tables
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">TableAlias</td>
    <td class="td_center">TableName</td>
    <td class="td_center">IsVTable</td>
    <td class="td_center">IsPrimary</td>
    <td class="td_center">IsSubSelect</td>
  </tr>
 <% it = vtable.getFromTables();
    while(it.hasNext())
    {
      OvalFromTable oft = (OvalFromTable)(it.next());
      %>
  <tr class="td_bg1">
    <td><%=JspHelper.filterNull( oft.getTableAlias())%></td>
    <td><%=JspHelper.filterNull( oft.getTableName())%></td>
    <td><%=JspHelper.filterNull( new Boolean(oft.getIsVTable()))%></td>
    <td><%=JspHelper.filterNull( new Boolean(oft.getIsPrimary()))%></td>
    <td><%=JspHelper.filterNull( new Boolean(oft.getIsSubSelect()))%></td>
  </tr>
 <% } %>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>


<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="mappingsHide" onclick="toggleMappings()" style="display:inline;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow3.gif"> 
      Mappings
    </td>
  </tr>
</tbody>
<tbody id="mappingsShow" onclick="toggleMappings()" style="display:none;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
      Mappings
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">Mapping Name</td>
    <td class="td_center">Left Mapping Table Alias</td>
    <td class="td_center">Left Mapping Field</td>
    <td class="td_center">Right Mapping Table Alias</td>
    <td class="td_center">Right Mapping Field</td>
    <td class="td_center">Mapping Type</td>
  </tr>
 <% it = vtable.getMappings();
    while(it.hasNext())
    {
      OvalMapping om = (OvalMapping)(it.next());
      %>
  <tr class="td_bg1">
    <td><%=JspHelper.filterNull( om.getMappingName())%></td>
    <td><%=JspHelper.filterNull( om.getLeftMappingTableAlias())%></td>
    <td><%=JspHelper.filterNull( om.getLeftMappingField())%></td>
    <td><%=JspHelper.filterNull( om.getRightMappingTableAlias())%></td>
    <td><%=JspHelper.filterNull( om.getRightMappingField())%></td>
    <td><%=JspHelper.filterNull( om.getMappingType())%></td>
  </tr>
 <% } %>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>


<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="qlHide" onclick="toggleQLs()" style="display:inline;">
  <tr> 
    <td colspan="1" class="td_title_bg">
      <img src="images/chinese/arrow3.gif"> 
        OvalQLs
    </td>
  </tr>
</tbody>
<tbody id="qlShow" onclick="toggleQLs()" style="display:none;">
  <tr> 
    <td colspan="3" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
        OvalQLs
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">QLName</td>
    <td class="td_center">ColumnViewName</td>
    <td class="td_center">Description</td>

  </tr>
 <% it = vtable.getOvalQLNames();
    while(it.hasNext())
    {
      OvalQL oq = vtable.getOvalQLByName(it.next().toString());
      %>
  <tr class="td_bg1">
    <td><a href="#" onclick="javascript:qltest('<%=JspHelper.filterNull( vtableName)%>','<%=JspHelper.filterNull( oq.getName())%>')"><%=JspHelper.filterNull( oq.getName())%></a></td>
    <td><%=JspHelper.filterNull( oq.getColumnViewName())%></td>
    <td><%=JspHelper.filterNull( oq.getDescription())%></td>
  </tr>
 <% } %>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>


<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="cdHide" onclick="toggleCDs()" style="display:inline;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow3.gif"> 
        Cascade Deletes
    </td>
  </tr>
</tbody>
<tbody id="cdShow" onclick="toggleCDs()" style="display:none;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
        Cascade Deletes
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">Delete Item Name</td>
    <td class="td_center">Delete Item Sequence</td>
    <td class="td_center">Is VTable</td>
    <td class="td_center">In Primary Table</td>
    <td class="td_center">In Cascade Table</td>
  </tr>
 <% OvalCascadeDelete ocd = vtable.m_DeleteItem;
    for(int i=0;i<ocd.getDeleteItemNum();i++)
    {
      String DeleteItemName = ocd.findDeleteItem(new Integer(i));
      Vector map = ocd.findDeleteMaping(new Integer(i));
      for(int j=0;j<map.size();j++)
      {
        String[] join = (String[])map.get(j);
        String cip = join[0];
        String cic = join[1];
          %>
  <tr class="td_bg1">
     <% if(ocd.getIsVtable(DeleteItemName))
        { %>
    <td>
      <a href="ShowVTable.jsp?nocache=&name=<%=JspHelper.filterNull( DeleteItemName )%>">
        <%=JspHelper.filterNull( DeleteItemName)%>
      </a>
    </td>
     <% }
        else
        { %>
    <td>
      <a href="ShowMTable.jsp?nocache=&name=<%=JspHelper.filterNull( DeleteItemName )%>">
        <%=JspHelper.filterNull( DeleteItemName)%>
      </a>
    </td>
     <% } %>
    <td><%=JspHelper.filterNull( i)%></td>
    <td><%=JspHelper.filterNull( new Boolean(ocd.getIsVtable(DeleteItemName)))%></td>
    <td><%=JspHelper.filterNull( cip)%></td>
    <td><%=JspHelper.filterNull( cic)%></td>
  </tr>
  <%  } %>
 <% }%>
</tbody>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<tbody id="cvHide" onclick="toggleCVs()" style="display:inline;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow3.gif"> 
        Column Views
    </td>
  </tr>
</tbody>
<tbody id="cvShow" onclick="toggleCDs()" style="display:none;">
  <tr> 
    <td colspan="6" class="td_title_bg">
      <img src="images/chinese/arrow2.gif"> 
        Column Views
    </td>
  </tr>
  <tr class="td_bg_row">
    <td class="td_center">Column View Name</td>
    <td class="td_center">Columns</td>
  </tr>
 <% 
    it = vtable.getColumnViews();
    while(it.hasNext())
    {
      String name = it.next().toString();
 %>    
   <tr class="td_bg1">
    <td class="td_center"><%=JspHelper.filterNull( name)%></td>
    <%
      String[] columnNames = vtable.findColumnView(name);
    %>
    <td class="td_center">
    <%
        String ColumnName = "";  
        for(int m=0;m<columnNames.length;m++)
        {
          ColumnName = ColumnName + "," + columnNames[m];
        }
    %>
    <%=JspHelper.filterNull( ColumnName.substring(1))%>
    </td>
  </tr>
  <%}%>

</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>


</body>
</html>

